$(function () {
    layui.use(['form'], function(){
        var form = layui.form
        //监听指定开关
        form.on('switch(switchTest)', function(){
            var checked = this.checked;
            // 获取value值
            var inputId = this.getAttribute("value")
            if (checked) {
                $("#" + inputId).attr("readonly",false);
            } else {
                $("#" + inputId).attr("readonly",true);
            }
        });
    });
})

// 保存页面数据
function saveData() {
    // limit_switch=on&parameter_configuration=1500.02
    var data = $("#common_configuartion").ghostsf_serialize();
    $.axse(
        hostUrl + "/commonParameterConfiguration/updateCommonConfiguration",
        data,
        function (data) {
            if (data.errcode == 200) {
                Layer.showSucMsg("保存成功");
                // 刷新页面数据
                location.reload();
            } else {
                Layer.showFailAlert("保存失败");
            }
        },
        function () {
            Layer.showFailAlert("保存配置数据请求失败，请稍后再试");
        }
    )
}